#include "reg51.h"
#include "intrins.h"

typedef unsigned int u16;
typedef unsigned char u8;

u8 ledNum;

sbit SRCLK = P3^6;
sbit RCLK = P3^5;
sbit SER = P3^4;
sbit LED = P0^7;

void delay(u16 i)
{
	while(i--);

}


void Hc595SendByte(u8 dat)
{
	u8 a;
	SRCLK = 1;
	RCLK = 1;
	for(a = 0; a < 8;a++)
	{
		SER = dat >> 7;
		dat <<= 1;
		SRCLK = 0;
		_nop_();
		_nop_();
		SRCLK = 1;

	}
	RCLK = 0;
	_nop_();
	_nop_();
	RCLK = 1;
}

void main()
{
	LED = 0;
	ledNum = ~0x01;
	while(1)
	{
		Hc595SendByte(ledNum);
		ledNum = _crol_(ledNum,1);
		delay(5000);
	}
}	

